package com.example.task2.customer;
import com.example.task2.infoapp.infoApp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

@Configuration  //在里面可以创建Bean定义的方法，比如编写commandlinerunner()
public class CustomerConfiguration {
    @Value("${app.useFakeCustomerDAO:false}")
    private Boolean useFakeCustomerDAO;

    @Value("${info.company.name}")
    private String companyName;

    @Autowired
    private Environment environment;
    @Bean
    CommandLineRunner commandLineRunner(infoApp infoapp){
        return args -> {
            System.out.println("ClR,hello");
            System.out.println(companyName);
            System.out.println(environment.getProperty("info.app.version"));
            System.out.println(infoapp);
        };
    }
    @Bean
    CustomerInterface customerInterface() {
        System.out.println("useFakeCustomerDAO: " + useFakeCustomerDAO);
        return  new CustomerFakeDAO() ;
    }
}
